using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using MishraReader.Entities;
using MishraReader.Entities.Tools;

namespace MishraReader.Services
{
    public interface IGoogleReaderService : INotifyPropertyChanged
    {
        IGoogleReaderConnector Connector { get; }

        /// <summary>
        ///   Gets if service is synchronizing with server
        /// </summary>
        bool IsSync { get; set; }

        /// <summary>
        ///   Gets the service state
        /// </summary>
        GoogleReaderService.ServiceStates ServiceState { get; }

        SubscriptionsList SubscriptionsList { get; }
        AsyncLock SyncRoot { get; }

        int UnreadCount { get; }
        Task Disconnect();

        /// <summary>
        ///   LoadAsync the service
        /// </summary>
        Task LoadAsync();

        Task<IEnumerable<Item>> LoadAllAsync(bool requestMoreData, IGoogleReaderStream category);
        Task<IEnumerable<Item>> LoadMoreStarredAsync(bool requestMoreData, IGoogleReaderStream category);
        Task<IEnumerable<Item>> LoadMoreUnreadAsync(bool requestMoreData, IGoogleReaderStream category);
        Task MarkAllAsReadAsync(IGoogleReaderStream subscriptionCategory);

        /// <summary>
        ///   Mark as read. The request is queued to prevent network overhead and unsafe collection access
        /// </summary>
        /// <param name="item"> </param>
        Task MarkAsReadAsync(Item item);

        /// <summary>
        ///   Mark as starred. The request is queued to prevent network overhead and unsafe collection access
        /// </summary>
        /// <param name="item"> </param>
        Task MarkAsStarredAsync(Item item);

        /// <summary>
        ///   Mark as unread. The request is queued to prevent network overhead and unsafe collection access
        /// </summary>
        /// <param name="item"> </param>
        Task MarkAsUnreadAsync(Item item);

        /// <summary>
        ///   Mark as unstarred. The request is queued to prevent network overhead and unsafe collection access
        /// </summary>
        /// <param name="item"> </param>
        Task MarkAsUnstarredAsync(Item item);

        /// <summary>
        /// </summary>
        Task<Tuple<bool, int>> RefreshUnreadAsync();

        void Reset();
        void UpdateUnreadCount();
    }
}